package cate.game.activity.loopfund.msg;

import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.activity.loopfund.LoopMonthFundActivity;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBTradeMall;
import easy.java.dev.note.NoteField;
import easy.java.practice.errorcode.EcResult;

@ClientMsg(title = "交易坊-循环月基金 领取奖励")
public class LoopMonthFundReceiveReq implements MsgInput {
    @NoteField("功能id")
    public int funcId;
    @NoteField(value = "配置ID")
    public int configId;

    @Override
    public MsgConfig conf() {
        return MsgIdBTradeMall.TRADE_MALL_LOOP_MONTH_FUND_RECEIVE_REQ;
    }

    @Override
    public void execute(GameBody game, ClientContext cc) {
        LoopMonthFundActivity single = cc.getRole().getActivity().getEnableActivitySingle(funcId);
        if (single == null) {
            cc.getRole().getGame().notice.message(cc.getRole(), "活动未开启");
            return;
        }
        GameResult<LoopMonthFundActivity> result = single.onReceiveLoopMonthFundReward(configId);
        if (result.ok()) {
            result.data.noticeUpdate();
        } else {
            game.notice.message(cc.getRole(), result.message);
        }
    }
}
